gdk: Move gdk_cursor_get_image() to the base class
authorBenjamin Otte <otte@redhat.com>
Mon, 20 Dec 2010 13:07:11 +0000 (14:07 +0100)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 21 Dec 2010 17:07:06 +0000 (12:07 -0500)
.. and make it call a vfunc on the cursor

gdk/gdkcursor.c
gdk/gdkcursorprivate.h
gdk/x11/gdkcursor-x11.c

index f6d229c36b1856500020e234d7ae26f2cde61575..fe5f38ced7ceb571d602b2bcbee8ec3731f71a4e 100644 (file)
@@ -374,3 +374,24 @@ gdk_cursor_get_display (GdkCursor *cursor)
   return cursor->display;
 }
 
+/**
+ * gdk_cursor_get_image:
+ * @cursor: a #GdkCursor
+ *
+ * Returns a #GdkPixbuf with the image used to display the cursor.
+ *
+ * Note that depending on the capabilities of the windowing system and 
+ * on the cursor, GDK may not be able to obtain the image data. In this 
+ * case, %NULL is returned.
+ *
+ * Returns: (transfer full): a #GdkPixbuf representing @cursor, or %NULL
+ *
+ * Since: 2.8
+ */
+GdkPixbuf*  
+gdk_cursor_get_image (GdkCursor *cursor)
+{
+  g_return_val_if_fail (GDK_IS_CURSOR (cursor), NULL);
+
+  return GDK_CURSOR_GET_CLASS (cursor)->get_image (cursor);
+}
index 51501d1906a58c5087358d82eb31ae35cbf15591..6a3a407d9b42452ae4f23e563169881367c758dd 100644 (file)
@@ -45,6 +45,8 @@ struct _GdkCursor
 struct _GdkCursorClass
 {
   GObjectClass parent_class;
+
+  GdkPixbuf *   (* get_image)   (GdkCursor *    cursor);
 };
 
 G_END_DECLS
index 5e0a966b12f3729edd0e2c36957ca96cb46d62c5..4fe6cef91ad966cad0a18f103bd90fb22f47420f 100644 (file)
@@ -181,6 +181,8 @@ _gdk_x11_cursor_display_finalize (GdkDisplay *display)
 
 G_DEFINE_TYPE (GdkX11Cursor, gdk_x11_cursor, GDK_TYPE_CURSOR)
 
+static GdkPixbuf* gdk_x11_cursor_get_image (GdkCursor *cursor);
+
 void
 gdk_x11_cursor_finalize (GObject *object)
 {
@@ -197,11 +199,14 @@ gdk_x11_cursor_finalize (GObject *object)
 }
 
 static void
-gdk_x11_cursor_class_init (GdkX11CursorClass *cursor_class)
+gdk_x11_cursor_class_init (GdkX11CursorClass *xcursor_class)
 {
-  GObjectClass *object_class = G_OBJECT_CLASS (cursor_class);
+  GdkCursorClass *cursor_class = GDK_CURSOR_CLASS (xcursor_class);
+  GObjectClass *object_class = G_OBJECT_CLASS (xcursor_class);
 
   object_class->finalize = gdk_x11_cursor_finalize;
+
+  cursor_class->get_image = gdk_x11_cursor_get_image;
 }
 
 static void
@@ -323,22 +328,8 @@ gdk_x11_cursor_get_xcursor (GdkCursor *cursor)
 
 #if defined(HAVE_XCURSOR) && defined(HAVE_XFIXES) && XFIXES_MAJOR >= 2
 
-/**
- * gdk_cursor_get_image:
- * @cursor: a #GdkCursor
- *
- * Returns a #GdkPixbuf with the image used to display the cursor.
- *
- * Note that depending on the capabilities of the windowing system and 
- * on the cursor, GDK may not be able to obtain the image data. In this 
- * case, %NULL is returned.
- *
- * Returns: (transfer full): a #GdkPixbuf representing @cursor, or %NULL
- *
- * Since: 2.8
- */
-GdkPixbuf*  
-gdk_cursor_get_image (GdkCursor *cursor)
+static GdkPixbuf*  
+gdk_x11_cursor_get_image (GdkCursor *cursor)
 {
   Display *xdisplay;
   GdkX11Cursor *private;
@@ -350,9 +341,7 @@ gdk_cursor_get_image (GdkCursor *cursor)
   GdkPixbuf *pixbuf;
   gchar *theme;
   
-  g_return_val_if_fail (cursor != NULL, NULL);
-
-  private = (GdkX11Cursor *) cursor;
+  private = GDK_X11_CURSOR (cursor);
     
   xdisplay = GDK_DISPLAY_XDISPLAY (gdk_cursor_get_display (cursor));
 
@@ -509,11 +498,9 @@ gdk_x11_display_set_cursor_theme (GdkDisplay  *display,
 
 #else
 
-GdkPixbuf*  
-gdk_cursor_get_image (GdkCursor *cursor)
+static GdkPixbuf*  
+gdk_x11_cursor_get_image (GdkCursor *cursor)
 {
-  g_return_val_if_fail (cursor != NULL, NULL);
-  
   return NULL;
 }